<template>
  <div
    style="
      height: 853px;
      padding-bottom: 37px;
      overflow: auto;
      overflow-x: hidden;
    "
  >
    <div style="margin-top: 20px; margin-bottom: 40px">
      <span class="tokenStyle">当前token：</span>
      <el-input v-model="input" style="width: 30%; margin-top: 20px">
      </el-input>
      <el-button round @click="chageTokenNum" style="margin-left: 20px"
        >提交修改</el-button
      >
    </div>
    <div style="text-align: center">
      <el-button @click="submit()">开始测试</el-button>
    </div>
  </div>
</template>

<script>
//import { mapState, mapGetters, mapActions } from "vuex";
import { mapState, mapActions } from "vuex";
import { reqUpdateTokenNum } from "@/api";

export default {
  data() {
    return {
      token_number: "",
      input: "",
    };
  },
  props: ["queryType", "company"],
  //   mounted() {
  //     this.getToken();
  //   },
  computed: {
    ...mapState(["curToken"]),
    // getTokenVal: {
    //   get() {
    //     return this.$store.state.curToken;
    //   },
    //   set(newVal) {
    //     this.$store.commit("handleVal", newVal);
    //   }
    // }
  },
  mounted() {
    this.input = this.curToken;
  },
  methods: {
    ...mapActions(["getQueryInfo", "changeTokenStateVal"]),
    async chageTokenNum() {
      let sendParams = {
        cur_token: this.input,
      };
      let resData = await reqUpdateTokenNum(sendParams);
      if (resData.code === 200) {
        this.$message({
          message: resData.msg,
          type: "success",
        });
        this.changeTokenStateVal(this.input);
      }
    },
    // getToken() {
    //   var token_num = this.curToken;
    // },
    submit() {
      let sendParams = {
        queryType: this.queryType,
        username: this.company,
      };
      this.getQueryInfo(sendParams);
    },
  },
};
</script>

<style>
.tokenStyle {
  font-size: 23px;
  font-weight: bold;
  text-align: right;
  vertical-align: middle;
  /* float: left; */
  line-height: 40px;
  padding: 0 12px 0 0 !important;
  box-sizing: border-box;
  color: #0d285d;
  margin-left: 25px;
}
</style>
